function q = ElnpZ_pi(mix, vars)

% E[ln p(Z|pi)]

Z = vars.Z;

if isfield(mix.varprior, 'a0')
    exp_logmix = dirichletln_exp(mix.varposterior.a);
else
    exp_logmix = log(mix.priors+realmin);
end

q = sum(sum(Z*exp_logmix'));
